﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ControllerStudy2.Controllers
{
    public class UploadFileController : Controller
    {
        //
        // GET: /UploadFile/
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Upload()
        {
            var hinh = Request.Files["hinh"];
            var tailieu = Request.Files["tailieu"];

            if (hinh != null && hinh.ContentLength > 0)
            {
                hinh.SaveAs(Server.MapPath("~/Upload/" + hinh.FileName));
                ViewBag.Hinh = "/Upload/" + hinh.FileName;
            }

            if (tailieu != null && tailieu.ContentLength > 0)
            {
                tailieu.SaveAs(Server.MapPath("~/Upload/" + tailieu.FileName));
                
                ViewBag.FileName = tailieu.FileName;
                ViewBag.FileType = tailieu.ContentType;
                ViewBag.FileSize = tailieu.ContentLength;
            }

            return View("UploadInfo");
        }
	}
}